package com.hermes.biz.search.deamon;

import java.util.ArrayList;
import java.util.List;

import com.hermes.biz.common.model.item.ItemDO;
import com.hermes.biz.common.util.string.StringUtil;
import com.hermes.biz.search.index.IndexManager;
import com.hermes.biz.search.logic.SearchLogic;
import com.hermes.biz.search.logic.UserSearchBean;
import com.hermes.biz.search.search.SearchManager;
import javax.annotation.Resource;
public class SearchService {	

	public IndexManager getIndexManager() {
		return indexManager;
	}

	public void setIndexManager(IndexManager indexManager) {
		this.indexManager = indexManager;
	}

	public SearchManager getSearchManager() {
		return searchManager;
	}

	public void setSearchManager(SearchManager searchManager) {
		this.searchManager = searchManager;
	}

	IndexManager indexManager;

	SearchManager searchManager;
	static SearchLogic searc = null;	
	//create index
	public void inita(){		
		try {	
			//create index
			indexManager.createIndexForItems("select item_id,item_title,tag_id,picture_url,description from item","C:\\Test\\item");
		} catch (Exception e) {			
			e.printStackTrace();
		}
	}
	
	/**
	 * search item by tag id
	 * @param tagId
	 * @return ItemDO List
	 */
	public  List<ItemDO> searchItemByWord(String wordStr,int topN){ 
		List<ItemDO> itemList = new ArrayList<ItemDO>();
		try {
			itemList = searchManager.getItemSearchResult(wordStr, topN);
		} catch (Exception e) {			
			e.printStackTrace();
		}
		return itemList;
	}
}
